#include <boost/functional/factory.hpp>
#include <kuai/misc/error.hpp>
#include <kuai/sim/trajec.hpp>

namespace kuai {

	/*
	void TrajecPlayer::seek(size_t frame) {
		throw NOT_IMPLEMENTED(seek);
	}

	void TrajecPlayer::start(std::ostream& stdlog, std::ostream& errlog, 
			PhaseSpace& space, std::vector<EnergyFunction*>& efunc, Index tid, Index nThreads)
	{
		if (tid == 0) {
			open();
		}
	}

	void TrajecPlayer::finish(std::ostream& stdlog, std::ostream& errlog, size_t iStep,
			PhaseSpace& space, std::vector<EnergyFunction*>& efunc, Index tid, Index nThreads) 
	{
		if (tid == 0) {
			close();
		}
	}

	void TrajecPlayer::act(std::ostream& stdlog, std::ostream& errlog, size_t iStep,
			PhaseSpace& space, std::vector<EnergyFunction*>& efunc, Index tid, Index nThreads) 
	{
		if (tid == 0) {
			size_t t = current();
			if (t == size_t(-1)) {
				throw EndOfTrajec(filename);
			}
			else if (iStep >= t) {
				update(space, tid, nThreads);
			}
		}
	}

	void TrajecPlayer::set(const String& key, const String& data) {
		if (boost::algorithm::iequals(key, "filename")) {
			filename = FileName(data);
		}
		else {
			throw UNDEFINED_MEMBER(key);		
		}
	}
	String TrajecPlayer::get(const String& key) const {
		if (boost::algorithm::iequals(key, "filename")) {
			return str(filename);
		}
		else {
			throw UNDEFINED_MEMBER(key);		
		}
	}

	TrajecPlayerFactory::TrajecPlayerFactory() {
		// (*this)[".trr"] = boost::factory<GromacsTrajecPlayer*>();
	}

	TrajecPlayer* TrajecPlayerFactory::create(const String& type) {
		static TrajecPlayerFactory singleton;
		TrajecPlayerFactory::const_iterator it = singleton.find(boost::algorithm::to_lower_copy(type));
		if (it == singleton.end()) {
			throw error("Unknow file type %1%", type);
		}
		else {
			return it->second();
		}
	};

	*/

}
